package Action;

import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.sql.Date;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import Dao.roomdao;
import Dao.scheduledao;
import Entity.Room;
import Entity.Room_ced;
import mapper.Roommapper;

import mapper.Schedulemapper;

/**
 * Servlet implementation class Room_Date
 */
@WebServlet("/Room_Date")
public class Room_Date extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public Room_Date() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#service(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String d = request.getParameter("data");
        java.util.Date da=null;
      
        try {
			da =sdf.parse("d") ;
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        Roommapper rm=new roomdao();
        List<Room> Room_list =rm.Room_query_all();
        Schedulemapper sm = new scheduledao();
        java.sql.Date date = new java.sql.Date(da.getTime());
        List<Room_ced> Room_ced_list =sm.Room_ced_QueryByDate(date);
        request.setAttribute("Room_list",Room_list);
        request.setAttribute("Room_ced_list",Room_ced_list);
        request.getRequestDispatcher("class_total.jsp").forward(request,response);
	}

}
